﻿using Minecraft.Model;

namespace Minecraft.Config.Csv.CsvCls
{
	public partial class Mod_Achieve
	{
		public int Id_Convert
		{
			get
			{
				return int.Parse(Id);
			}
		}
		public int Level_Convert
		{
			get
			{
				return int.Parse(Level);
			}
		}
		public int Last_id_Convert
		{
			get
			{
				return int.Parse(Last_id);
			}
		}


		/// <summary>
		/// 获取ConditionType的类型
		/// </summary>
		public EnumAchievementConditionType enumConditionType_Convert
		{
			get
			{
				var conditionType = Condition.Split('#')[0];

				if (string.IsNullOrEmpty(conditionType))
				{
					return EnumAchievementConditionType.None;
				}

				conditionType = conditionType.ToLower().Trim();
				switch (conditionType)
				{
					case "level":
						return EnumAchievementConditionType.Level;
					case "blue":
						return EnumAchievementConditionType.Blue;
					case "blueid":
						return EnumAchievementConditionType.BlueId;
					case "monster":
						return EnumAchievementConditionType.Monster;
					case "monsterid":
						return EnumAchievementConditionType.MonsterIdNum;
					case "def1":
						return EnumAchievementConditionType.Def1;
					case "def2":
						return EnumAchievementConditionType.Def2;
					case "att":
						return EnumAchievementConditionType.Att;
					case "connect":
						return EnumAchievementConditionType.Connect;
					default:
						return EnumAchievementConditionType.None;
				}
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public int ConditionNum_Convert
		{
			get
			{
				var conditionNum = 0;
				var conditionId = 0;

				if (Condition.Contains("|"))
				{
					conditionNum = int.Parse(Condition.Split('|')[1]);
					conditionId = int.Parse(Condition.Split('|')[0].Split('#')[1]);
				}
				else
				{
					conditionNum = int.Parse(Condition.Split('#')[1]);
				}

				return conditionNum;
			}
		}

		
		/// <summary>
		/// 
		/// </summary>

		public int ConditionId_Convert
		{
			get
			{
				var conditionNum = 0;
				var conditionId = 0;

				if (Condition.Contains("|"))
				{
					conditionNum = int.Parse(Condition.Split('|')[1]);
					conditionId = int.Parse(Condition.Split('|')[0].Split('#')[1]);
				}
				else
				{
					conditionNum = int.Parse(Condition.Split('#')[1]);
					conditionId = 0;
				}

				return conditionId;
			}
		}

	}
}
